package com.chennan.book.domain.service;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;

/**
 * @author chennan
 * @create 2022-02
 */
public class RunExecuteTask implements Runnable{

    public static AtomicLong atomicLong = new AtomicLong(0);

    private String name;

    public RunExecuteTask(String name){
        this.name = name;
    }

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"###"+this.name);
        for (int i = 0; i < 1000; i++) {
            try {
                RunExecuteTask.atomicLong.addAndGet(1);
                TimeUnit.MILLISECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
